import { createRouter, createWebHistory } from 'vue-router'

import {routes} from "@/router/initial.js"


/*
 createWebHistory();H5模式
 createWebHashHistory();hash 模式: #
*/
const router = createRouter({
  history: createWebHistory(),
  routes,
})
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'

import store from '@/store'

router.beforeEach((to, from, next) => {
  store.state.configuration.DP_TITLE ? (window.document.title = to.meta.title) : (window.document.title = import.meta.env.VITE_APP_TITLE);//动态title标题
  NProgress.start() //开启进度条
  next();
})
router.afterEach((to, from) => {
  NProgress.done(); //进入之后关闭进度条
})

export default router